package com.example.dell.fastshopping.user.address;

import com.example.dell.fastshopping.DuoBao.entity.PriductInfo;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ${YSH} on 2019/5/22.
 * 描述        ${TODO}
 * <p>
 * 更新者       $author$
 * 更新时间     $Data$
 * 描述         ${TODO}
 */
public class AddressEntity {
    private List<Province> province;

    public void setProvince(List<Province> province) {
        this.province = province;
    }

    public List<Province> getProvince() {
        return province;
    }


    public List<List<List<String>>> getAllArealList() {
        ArrayList<List<List<String>>> list = new ArrayList<>();
        for (Province p : province) {
            ArrayList<List<String>> list1 = new ArrayList<>();
            for (City c : p.getCity()) {
                ArrayList<String> strings = new ArrayList<>();
                strings.addAll(c.getArea());
                list1.add(strings);
            }
            list.add(list1);
        }
        return list;
    }

    public List<List<String>> getAllCityList() {
        ArrayList<List<String>> list = new ArrayList<>();
        for (Province p : province) {
            ArrayList<String> strings = new ArrayList<>();
            for (City c : p.getCity()) {
                strings.add(c.getName());
            }
            list.add(strings);
        }
        return list;
    }

    public List<String> getProvinceList() {
        ArrayList<String> strings = new ArrayList<>();
        for (Province p : province) {
            strings.add(p.getName());
        }
        return strings;
    }


    private class Province {
        private String name;

        private List<City> city;

        public void setName(String name) {
            this.name = name;
        }

        public void setCity(List<City> city) {
            this.city = city;
        }

        public String getName() {
            return name;
        }

        public List<City> getCity() {
            return city;
        }

    }


    private class City {
        private String name;
        private List<String> area;

        public void setName(String name) {
            this.name = name;
        }

        public void setArea(List<String> area) {
            this.area = area;
        }

        public String getName() {
            return name;
        }

        public List<String> getArea() {
            return area;
        }
    }

}
